package com;
import java.util.ArrayList;
import java.util.Vector;
import java.util.Scanner;
public class ScoreTest {
    public static void main(String[] args) {
        Vector v=new Vector();// 创建Vector对象
        ArrayList<Object> list=new ArrayList<>();
        Scanner scan=new Scanner(System.in);
        int maxScore=0;
        while(true){
            System.out.println("请输入学生成绩(输入负数即结束):");
            int score=scan.nextInt();
            if(score<0){
                break;
            }
            if(score>100){
                System.out.println("输入的数据非法，请重新输入:");
                continue;
            }
            v.addElement(score);//自动装箱并多态
            if(score>maxScore){
                maxScore=score;
            }
        }
        char level=0;
        //遍历容器，得到每个学生成绩并与最大值作比较
        for(int i=0;i<v.size();i++){
            Object object=v.elementAt(i);
            Integer integer=(Integer)object;
            if(maxScore-integer<=10){
                level='A';
            }else if(maxScore-integer<=20){
                level='B';
            }else if(maxScore-integer<=30){
                level='C';
            }else{
                level='D';
            }
            System.out.println("Student-"+i+"score is"+integer+"level is"+level);
        }
    }
}
